define(function(require, exports, module){
	/**
	 * @class Storage
	 * @memberof Nuui
	 * @classdesc json实现的简单存储器,使用中App.storage即为此类型
	 * @example var storage = new Nuui.Storage();
	 * storage.set("a", "123");
	 * storage.get("a"); // 123
	 */
	var Storage = module.exports = function(){
		this.db = {};
	};

	_.extend(Storage.prototype, {
		
		/**
		 * @desc 根据key获取value
		 * @memberof Nuui.Storage
		 * @func get
		 * @instance
		 * @param {string} key - value的key值
		 * @returns {?} key值对应的value
		 */
		get:function(key){
			return this.db[key];
		},

		/**
		 * @desc 将value设置到key值中
		 * @memberof Nuui.Storage
		 * @func set
		 * @instance
		 * @param {string} key - value的key值
		 * @param {?} value - value
		 */
		set:function(key, value){
			this.db[key] = value;
		},

		/**
		 * @desc 按照key值清除value
		 * @memberof Nuui.Storage
		 * @func remove
		 * @instance
		 * @param {string} key - value的key值
		 * @returns {?} key值对应的value
		 */
		remove:function(key){
			var value = this.db[key];
			delete this.db[key];
			return value;
		},
		
		/**
		 * @desc 清除所有内容
		 * @memberof Nuui.Storage
		 * @func clear
		 * @instance
		 */
		clear:function(){
			this.db = {};
		},
        setCookieSession:function (key,obj){
            window.localStorage.setItem(key,JSON.stringify(obj));
        },
        getCookieSession:function (key){
            var obj = window.localStorage.getItem(key);
            obj = obj ? JSON.parse(obj) : [];
            return obj;
        },
        removeCookieSession:function (key) {
            window.localStorage.removeItem(key);
        }
	});

});
